.\"     Title: \fBndb_size.pl\fR
.\"    Author: 
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
.\"      Date: 03/31/2009
.\"    Manual: MySQL Database System
.\"    Source: MySQL 5.1
.\"
.TH "\fBNDB_SIZE.PL\fR" "1" "03/31/2009" "MySQL 5.1" "MySQL Database System"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
ndb_size.pl \- NDBCLUSTER Size Requirement Estimator
.SH "SYNOPSIS"
.HP 22
\fBndb_size.pl \fR\fB\fIarguments\fR\fR
.SH "DESCRIPTION"
.PP
This is a Perl script that can be used to estimate the amount of space that would be required by a MySQL database if it were converted to use the
NDBCLUSTER
storage engine. Unlike the other utilities discussed in this section, it does not require access to a MySQL Cluster (in fact, there is no reason for it to do so). However, it does need to access the MySQL server on which the database to be tested resides.
.PP
\fBRequirements\fR:
.TP 3n
\(bu
A running MySQL server. The server instance does not have to provide support for MySQL Cluster.
.TP 3n
\(bu
A working installation of Perl.
.TP 3n
\(bu
The
DBI
module, which can be obtained from CPAN if it is not already part of your Perl installation. (Many Linux and other operating system distributions provide their own packages for this library.)
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
\fBNote\fR
Previous to MySQL 5.1.18,
\fBndb_size.pl\fR
also required the
HTML::Template
module and an associated template file
\fIshare/mysql/ndb_size.tmpl\fR. Beginning with MySQL 5.1.18,
\fIndb_size.tmpl\fR
is no longer needed (or included).
.TP 3n
\(bu
A MySQL user account having the necessary privileges. If you do not wish to use an existing account, then creating one using
GRANT USAGE ON \fIdb_name\fR.*
\(em where
\fIdb_name\fR
is the name of the database to be examined \(em is sufficient for this purpose.
.sp
.RE
.PP
\fIndb_size.pl\fR
can also be found in the MySQL sources in
\fIstorage/ndb/tools\fR. If this file is not present in your MySQL installation, you can obtain it from the
[1]\&\fIMySQL Forge project page\fR.
.PP
\fBUsage\fR:
.PP
.sp
.RS 3n
.nf
ndb_size.pl [\-\-database=\fIdb_name\fR|ALL] [\-\-hostname=\fIhost\fR[:\fIport\fR]] [\-\-socket=\fIsocket\fR] [\-\-user=\fIuser\fR] \\
    [\-\-password=\fIpassword\fR] [\-\-help|\-h] [\-\-format=(html|text)] [\-\-loadqueries=\fIfile_name\fR] [\-\-savequeries=\fIfile_name\fR]
.fi
.RE
.sp
.PP
By default, this utility attempts to analyze all databases on the server. You can specify a single database using the
\fB\-\-database\fR
option; the default behavior can be made explicit by using
ALL
for the name of the database. You can also exclude one or more databases by using the
\fB\-\-excludedbs\fR
with a comma\-separated list of the names of the databases to be skipped. Similarly, you can cause specific tables to be skipped by listing their names, separated by commas, following the optional
\fB\-\-excludetables\fR
option. A host name (and possibly a port as well) can be specified using
\fB\-\-hostname\fR; the default is
localhost:3306. If necessary, you can specify a socket; the default is
\fI/var/lib/mysql.sock\fR. A MySQL user name and password can be specified the corresponding options shown. It also possible to control the format of the output using the
\fB\-\-format\fR
option; this can take either of the values
html
or
text, with
text
being the default. An example of the text output is shown here:
.sp
.RS 3n
.nf
shell> \fBndb_size.pl \-\-database=test \-\-socket=/tmp/mysql.sock\fR
ndb_size.pl report for database: 'test' (1 tables)
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
Connected to: DBI:mysql:host=localhost;mysql_socket=/tmp/mysql.sock
Including information for versions: 4.1, 5.0, 5.1
test.t1
\-\-\-\-\-\-\-
DataMemory for Columns (* means varsized DataMemory):
              Column Name                 Type  Varsized   Key       4.1        5.0        5.1
          HIDDEN_NDB_PKEY               bigint             PRI         8          8          8
                       c2          varchar(50)         Y              52         52         4*
                       c1              int(11)                         4          4          4
                                                                      \-\-         \-\-         \-\-
Fixed Size Columns DM/Row                                             64         64         12
   Varsize Columns DM/Row                                              0          0          4
DataMemory for Indexes:
               Index Name                 Type        4.1        5.0        5.1
                  PRIMARY                BTREE         16         16         16
                                                       \-\-         \-\-         \-\-
       Total Index DM/Row                              16         16         16
IndexMemory for Indexes:
               Index Name        4.1        5.0        5.1
                  PRIMARY         33         16         16
                                  \-\-         \-\-         \-\-
           Indexes IM/Row         33         16         16
Summary (for THIS table):
                                 4.1        5.0        5.1
    Fixed Overhead DM/Row         12         12         16
           NULL Bytes/Row          4          4          4
           DataMemory/Row         96         96         48  (Includes overhead, bitmap and indexes)
  Varsize Overhead DM/Row          0          0          8
   Varsize NULL Bytes/Row          0          0          4
       Avg Varside DM/Row          0          0         16
                 No. Rows          0          0          0
        Rows/32kb DM Page        340        340        680
Fixedsize DataMemory (KB)          0          0          0
Rows/32kb Varsize DM Page          0          0       2040
  Varsize DataMemory (KB)          0          0          0
         Rows/8kb IM Page        248        512        512
         IndexMemory (KB)          0          0          0
Parameter Minimum Requirements
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
* indicates greater than default
                Parameter          Default             4.1              5.0              5.1
          DataMemory (KB)            81920               0                0                0
       NoOfOrderedIndexes              128               1                1                1
               NoOfTables              128               1                1                1
         IndexMemory (KB)            18432               0                0                0
    NoOfUniqueHashIndexes               64               0                0                0
           NoOfAttributes             1000               3                3                3
             NoOfTriggers              768               5                5                5
.fi
.RE
.sp
.PP
For debugging purposes, the Perl arrays containing the queries run by this script can be read from the file specified using can be saved to a file using
\fB\-\-savequeries\fR; a file containing such arrays to be read in during script execution can be specified using
\fB\-\-loadqueries\fR. Neither of these options has a default value.
.PP
To produce output in HTML format, use the
\fB\-\-format\fR
option and redirect the output to a file, as shown in this example:
.sp
.RS 3n
.nf
shell> \fBndb_size.pl \-\-database=test \-\-socket=/tmp/mysql.sock \-\-format=html > ndb_size.html\fR
.fi
.RE
.sp
(Without the redirection, the output is sent to
stdout.) This figure shows a portion of the generated
\fIndb_size.html\fR
output file, as viewed in a Web browser:
.PP
The output from this script includes:
.TP 3n
\(bu
Minimum values for the
DataMemory,
IndexMemory,
MaxNoOfTables,
MaxNoOfAttributes,
MaxNoOfOrderedIndexes,
MaxNoOfUniqueHashIndexes, and
MaxNoOfTriggers
configuration parameters required to accommodate the tables analyzed.
.TP 3n
\(bu
Memory requirements for all of the tables, attributes, ordered indexes, and unique hash indexes defined in the database.
.TP 3n
\(bu
The
IndexMemory
and
DataMemory
required per table and table row.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
\fBNote\fR
.PP
Prior to MySQL 5.1.23, MySQL Cluster NDB 6.2.5, and MySQL Cluster NDB 6.3.7,
\fIndb_size.pl\fR
was invoked as shown here:
.sp
.RS 3n
.nf
perl ndb_size.pl \fIdb_name\fR \fIhostname\fR \fIusername\fR \fIpassword\fR > \fIfile_name\fR.html
.fi
.RE
.sp
For more information about this change, see
[2]\&\fIBug#28683\fR
and
[3]\&\fIBug#28253\fR.
.SH "COPYRIGHT"
.PP
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
.PP
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
.PP
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
.PP
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA or see http://www.gnu.org/licenses/.
.SH "REFERENCES"
.TP 3
1.\ MySQL Forge project page
\%http://forge.mysql.com/projects/project.php?id=88
.TP 3
2.\ Bug#28683
\%http://bugs.mysql.com/28683
.TP 3
3.\ Bug#28253
\%http://bugs.mysql.com/28253
.SH "SEE ALSO"
For more information, please refer to the MySQL Reference Manual,
which may already be installed locally and which is also available
online at http://dev.mysql.com/doc/.
.SH AUTHOR
MySQL AB (http://www.mysql.com/).
